<?php

class Controller_Site extends Controller_Base
{

    public $template = 'layouts/site';

    public function before()
    {
        parent::before();
        // Load style
        Asset::css(array (
        	'plugins/multiselect.css',
			'styles/icons.css', 
			'styles/site.css'
		), array (), 'css', false);
		// js
		Asset::js(array(
			'app.js', 
			'funcs.js'
		), array(), 'js', false);
        Asset::js(array(
			'lib/form.js', 
			'plugins/jquery.uniform.js', 
			'plugins/jquery.multiselect.js'
		), array(), 'jquery', false);
    }

	public function after($response)
	{
		$response = parent::after($response);
		
		// set title
		if(is_null($this->title))
		{
			$this->title = ucwords(str_replace('_', ' ', Request::active()->action));
		}
		$this->set('title', $this->title);

		// set template content
		if ( empty($this->template->content) )
		{
			$controller = strtolower(str_replace(Config::get('controller_prefix'), '', Request::active()->controller));
			$controller = str_replace('_', '/', $controller);
			$this->template->content = View::forge($controller . '/' . Request::active()->action, $this->data);
		}

		return $response;
	}

}